package com.copractice.bl.question;


import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Represents question which is transfering between backing
 * bean and business logic class.
 * 
 * @author Dmitry Churbanov (dmitry.churbanov@gmail.com)
 * @version 1.0 04/14/2009
 */
public class QuestionToSave {
    
    private String questionText;
    private String defaultHint;
    private Long categoryId;
    private String newCategoryName;
    
    private String rightAnswer;
    private List<String> answers;
    
    private Long difficulty;
    
    public QuestionToSave(String text) {
        this.questionText = text;
    }
    
    public QuestionToSave addHint(String hint) {
        this.defaultHint = hint;
        return this;
    }
    
    public QuestionToSave addCategoryName(String categoryName) {
        this.newCategoryName = categoryName;
        return this;
    }
    
    public QuestionToSave addAnswers(List<String> answers, String rightAnswer) {
        if (this.answers == null) {
            this.answers = new ArrayList<String>();
        }
        this.answers.addAll(answers);
        this.rightAnswer = rightAnswer;
        return this;
    }
    
    public QuestionToSave addDifficulty(Long difficulty) {
        this.difficulty = difficulty;
        return this;
    }

    public String getQuestionText() {
        return questionText;
    }

    public void setQuestionText(String questionText) {
        this.questionText = questionText;
    }

    public String getDefaultHint() {
        return defaultHint;
    }

    public void setDefaultHint(String defaultHint) {
        this.defaultHint = defaultHint;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getNewCategoryName() {
        return newCategoryName;
    }

    public void setNewCategoryName(String newCategoryName) {
        this.newCategoryName = newCategoryName;
    }

    public String getRightAnswer() {
        return rightAnswer;
    }

    public void setRightAnswer(String rightAnswer) {
        this.rightAnswer = rightAnswer;
    }

    public List<String> getAnswers() {
        return answers;
    }

    public void setAnswers(List<String> answers) {
        this.answers = answers;
    }

    public Long getDifficulty() {
        return difficulty;
    }

    public void setDifficulty(Long difficulty) {
        this.difficulty = difficulty;
    }
    
    /**
     * Returns a string representation of the entity.
     * 
     * @return a string representation of the entity.
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("questiontext", getQuestionText())
                .append("categoryId", getCategoryId())
                .append("newCategoryName", getNewCategoryName())
                .append("defaultHint", getDefaultHint())
                .append("difficulty", getDifficulty())
                .append("answers", getAnswers())
                .append("rightAnswer", getRightAnswer())
                .toString();
    }    
    
}